<!DOCTYPE html>
<title>Element#requestFullscreen() followed by removing the element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<div id="target"></div>
<script>
async_test(t => {
  const target = document.getElementById("target");

  document.onfullscreenchange = t.unreached_func("fullscreenchange event");
  document.onfullscreenerror = t.step_func_done(event => {
    assert_equals(document.fullscreenElement, null, "fullscreen element");
    assert_equals(event.target, document, "event target");
  });

  trusted_click(t, () => {
    target.requestFullscreen();
    target.remove();
  }, document.body);
});
</script>
